package com.company.JUC.AQS.CountDownLatch;

import java.util.concurrent.CountDownLatch;

/**
 * @Classname MyCircularQueue
 * @Description TODO
 * @Date 2021/8/18 17:05
 * @Created by ylr
 */
public class Main {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);//初始化计数器为6
        //6个线程
        for (int i = 0; i < 6; i++) {
            new Thread(()->{
                countDownLatch.countDown();//计数器减一
                System.out.println(Thread.currentThread().getName()+"  离开了教室...");

            },String.valueOf("小"+i)).start();
        }
        //阻塞
        countDownLatch.await();//线程调用await()该线程会被阻塞  直到countDownLatch==0   计数器为0唤醒await线程
        System.out.println("没人了 关门!");
    }
}
